Finding and Replacing Text in Task Steps

Task Builder encompasses a comprehensive Find and Replace feature that enables you to search for every occurrence of a particular word or phrase in one or more open tasks, and optionally, replace them with the specified text. You can scope searches to the current task, current function, selected steps or all open tasks. Options and rules that you set can restrict the results to those that meet the criteria that you specify. For example, you can specify what direction you want to search or require that only text that matches the case of the text you entered should be found.

The Find and Replace controls are located in Task Builder's ribbon under the Home tab. To determine related hot-keys, hover your cursor over each control.

Finding text

The Find dialog searches through the AML code of the selected step or function, current task, or all open tasks (depending on the search options you choose). When finding one instance of text at a time, clicking Find highlights the next instance of text found.

To find text in one or more steps/tasks

  1. In the Steps panel, click the step from which you want to start the search or specific steps you want to include in the search. To select more than one step, hold down CTRL during selection.
  2. From Task Builder's ribbon, select the Home tab and click Find or press CTRL + F. The Find dialog appears.
  3. In the Find dialog, do the following:
Use this... To do this...
Look in Select the scope of the search:
  • Current task - Search the AML of the current task.
  • Current function - Search the current function.
  • Selected steps - Search only the selected steps.
  • All open tasks - Search all tasks open in the Task Builder. The Task Builder application (AMTB.exe) must be opened directly in order for it to display multiple tasks. If it is opened by way of a managed task, then
Find what Type the text you want to search for.
Match case Find text only if it matches the case of the text you typed.
Match whole words Find text only if it matches the whole word you typed.
Regular expression Use regular expressions (notations for patterns of text) rather than the literal character. For more information, see Regular expressions for finding text below.
Search up Searches will be performed from the bottom to the top.
Wrap searches Automate Desktop will search for the specified text beginning at the point in the document where you are currently positioned, and will continue past the end, to the beginning of the document back to your current position. In other words, wrap search will search the entire document irrespective of where you may be positioned within it
  1. Click Find . The found text (if any) is highlighted in the task.
  2. Repeat clicking Find to find additional instances of the text.
  3. Click Close when finished.
NOTE: You can close the Find dialog and still find the next instance by clicking Find Next on the ribbon.

Replacing text

You can automatically replace text using the Replace dialog. This dialog has the same functionality as Find but allows you to make text substitutions in the current function, steps or tasks as shown below.

To replace text in a task

  1. From the Task Builder ribbon, select the Home tab and click Replace. This opens the Replace dialog
  2. In the Replace dialog, do one of the following:
Use this... To do this...
Look in Select the scope of the search:
  • Current task - Search and replace text from the AML of the current task.
  • Current function - Search and replace text found in the current function.
  • Selected steps - Search and replace text from the selected task steps.  
  • All open tasks - Search and replace text within all open tasks in the Task Builder. The Task Builder application (AMTB.exe) must be opened directly in order for it to display multiple tasks. If it is opened by way of a managed task, then
Find what Type the text you want to search for.
Replace with Type the text you want to replace the original text with.
Match case Find text only if it matches the case of the text you typed.
Match whole words Find text only if it matches the whole word you typed.
Regular expression Use regular expressions (notations for patterns of text) rather than the literal character. For more information, see Regular expressions for finding text below.
Search up Searches will be performed from the bottom to the top.
  1. Select one of the following:
    • To find one instance of the specified text at a time, click Find Next. The next instance is selected in the Steps panel in AML view. Repeat clicking Find Next to find additional instances of the text.
    • To replace the current text instance with the new text, click Replace.
    • To replace the ensuing text instance with the new text, click Replace Next. Repeat clicking Replace Next to replace additional instances with the new text.
    • To replace all instances of the specified text with the new text at the same time, click Replace All.
  1. Click Close when finished.

Regular expressions for finding text

You can perform sophisticated find and replace operations in the Task Builder by using regular expressions. Regular expressions are useful when you do not know the exact text or code you are looking for, or when you are looking for all occurrences of strings of text or code with one or more similarities.

A regular expression is a pattern of text that describes one or more variations of text or code that you want to find. A regular expression consists of specific characters, such as the letters a through z and special characters that describe the pattern of text, such as an asterisk (*). For example, to find all variations of the word page in your task, you can enter page*. This finds all instances of page, pages, pager, and any other words that begin with page in your task.

When you use regular expressions in your searches, there are specific rules that control which combination of characters perform specific matches. Each regular expression or combination of regular expressions is referred to as syntax. You can use multiple regular expressions in one syntax to precisely target your search. The following table displays a list of common expression syntax and their description.

Syntax Expression Description
. Any character acts as a wild card to match any single printing or non-printing character with the exception of the newline (\n)character. For example, the regular expression c.t matches the strings cat, c t, cot, but not cost. In this example, the period (.) is a wild card for a single character. It appears between the letters 'c' and 't', so any single character between the characters 'c' and 't' will match the expression—even if it is a space.
* Maximal — zero or more matches zero or more occurrences of a character that precede the expression, matching as many characters as possible.

The regular expression .* matches zero or more occurrences of one character.For example, the regular expression b.*k matches book, back, black, blank, and buck.

In this example, we combine the period (.) with the asterisk (*) to make one syntax. The period (.) appears immediately before the asterisk (*) expression. The asterisk (*) matches zero or more occurrences of any character between 'b and 'k'. The period (.) acts as a wild card for the characters between 'b' and 'k'. In this example, it means that any character between 'b' and 'k' can be repeated.
+ Maximal — one or more matches one or more occurrences of a character that precede the expression, matching as many characters as possible.

The regular expression .+ matches one or more occurrence of one character.For example, the regular expression bo+. matches bob, book, and boot.

In this example, we combine the period (.) with the plus sign (+) to make one syntax. The period (.) appears immediately after the plus sign (+) expression. The plus sign (+) matches one or more occurrences of the letter 'o'. The period (.) acts as a wild card for the last character of each word, which, in this example are 'b', 'k', and 't'.
@ Minimal—zero or more matches zero or more occurrences of a character that precede the expression, matching as few characters as possible.

The regular expression .@ means match zero or more occurrences of one character. For example, the regular expression a.@x matches 'abx' within '
# Minimal—one or more matches one or more occurrences of a character that precede the expression, matching as few characters as possible. For example, the regular expression si.#er matches 'sicker' or 'silkier'. In this example, we combine the period (.) with the sharp sign (#) to make one syntax. The period (.) appears immediately before the sharp sign (#) expression. The sharp sign (#) matches one or more occurrences of any character between 'si' and '
[ ] Set of characters matches any one of the characters within the brackets ([ ]). You can specify ranges of characters by using a hyphen (-), as in [a-z]. Examples:
  • The regular expression c[aou]t matches cat, cot, and cut, but not
  • The regular expression [0-9] means match any digit. You can specify multiple ranges of letters as well.
  • The regular expression [A-Za-z] means match all upper and lower case letters.
^ Beginning of line anchors the match to the beginning of a line. For example, the regular expression ^When in matches the any string that begins with "When in" and that also appears at the beginning of a line, such as "When in the course of human events" or "When in town, call me". Whereas, this regular expression does not match "What and when in the course of human events" if it appears at the beginning of a line.
$ End of line anchors the match to the end of a line. For example, the regular expression professional$ matches the end of the string "He is a professional" but not the string "They are a group of professionals".
^^ Beginning of file anchors the match to the beginning of a file. Works only when searching for text in source code or in text files. For example, to match the first HTML tag at the beginning of a file, use the following regular expression: ^^
$$ End of file anchors the match to the end of a file. Works only when searching for text in source code or in text files. For example, to match the last HTML tag at the end of a file (with no spaces following the tag), use the following regular expression: $$
| Or indicates a choice between two items, thereby matching the expression before or after the OR symbol (|). For example, the regular expression (him|her) matches the following occurrences it belongs to him or it belongs to her but it does not match the line it belongs to them.
\ Escape special character matches the character following the back slash ( \ ). This allows you to find characters that are used in the regular expression syntax, such as a left curly brace ({) or a caret (^) or some other special character.

For example, you can use \$ to match the dollar sign character ($) rather than implementing the regular expression to 'anchor to end of a line'. Similarly, you can use the expression \. to match the period (.) character rather than match any single character, which is what the period (.) regular expression does.
{} Tagged expression tags the text matched by the enclosed expression. You can match another occurrence of the tagged text in a Find expression or insert the tagged text in a Replace expression using \N.

For example, suppose you are looking to find two duplicate, consecutive words. To search, use the following expression: {.#} \1

With the assumption that the consecutive words are separated by a single space, you'll want to add a space between the right curly brace (}) and the back slash ( \ ).

In this example, we combine the sharp sign (#) and the period (.) with the curly braces ({}) to make one syntax. In this expression, .# represents any consecutive characters. Since this portion of the expression is surrounded by curly braces ({}), the consecutive characters will be tagged and can be referred to as \1. This expression will find any consecutive characters followed by a space, followed by those exact same consecutive characters.
\N Nth tagged expression in a Find expression, \N matches the text matched by the Nth tagged expression, where N is a number from 1 to 9.

In a Replace expression, \N inserts the text matched by the Nth tagged expression where N is a number from 1 to 9. \0 inserts the text matched by the entire Find expression.

For example, suppose you want to find two duplicate, consecutive words and replace them with a single word. To search, use the following expression: {.#} \l

With the assumption that the consecutive words are separated by a single space, you'll want to add a space between the right curly brace (}) and the back slash ( \ ). In this example, we combined the sharp sign (#) and the period (.) with the curly braces ({}) to make one syntax.

To replace, use the following expression: \l

\1 represents what was found in the first pair of curly braces in the find string. By using \1 in the replace action, you essentially replace the duplicate, consecutive words with a single copy of the word.
( ) Group expression marks the beginning and end of a sub expression.

A sub expression is a regular expression that you enclose in parenthesis ( ), such as the expression that follows: (ha)+ In this example, we combine the plus sign (+) with the parenthesis ( ) group expression to make one syntax. The sub expression is (ha) because it is encapsulated within the parenthesis ( ). When you add the plus sign (+), the expression enables you to find repeating pairs of letters. The plus sign (+) represents one or more occurrences of 'ha'.

This expression matches the following occurrences 'haha' and '
~x Prevent match  prevents a match when x appears at this point in the expression. For example, the regular expression real~(ity) matches the real in realty and really, but prevents the match to real in reality.
\n Line break matches a new line in Code view, or a <br inDesignview.

The syntax (\n), is a shorthand approach to enable you to match all line breaks.
\t Tab matches a single tab character. For example, if you want to find all single tabbed characters at the beginning of a line, the regular expression would look like the following:

^\t+

In this example, we combine the caret (^) and the plus sign (+) with the tab (\t) to make one syntax. The caret (^) that precedes the single tab character expression, anchors the match to all tabbed characters at the beginning of the line. The plus sign (+) represents the matching of one or more tab characters.
[^] Any one character not in the set matches any character that is not in the set of characters that follows the caret (^).

For example, to match any character except those in the range, use the caret (^) as the first character after the opening bracket. The expression [^269A-Z] will match any characters except 2, 6, 9, and any upper case alphabetical characters.
n Repeat expression matches n occurrences of the expression that precedes the caret (^).

For example, with n equaling 4, the expression [0-9]^4 matches any 4-digit sequence. In this example, we combine the set of characters ([ ]) syntax with the repeat (^n) syntax to demonstrate a more realistic use of regular expressions.
:a Alphanumeric character matches the expression [a-zA-Z0-9].

You can use the following expression: [a-zA-Z0-9] to match one occurrence of a letter (upper case or lower case) or number. Also known as alphanumeric occurrences. You can use the shorthand expression :a for all instances of [a-zA-Z0-9].
:b White space matches any white spaces in code or text.

For example, to match a single white space character at the beginning of a line, use the following regular expression:^:b
:c Alphabetic character matches the expression [a-zA-Z]When you use this expression, it enables you to match all upper or lower case letters.

You can use the shorthand expression :c for all instances of [a-zA-Z].
:d Decimal digit matches the expression[0-9]This expression enables you to match any digit.

For example, suppose you want to find a social security number in a text file. The format for U.S. social security numbers is 999-99-9999. :d^3-:d^2-:d^4 or, by using [0-9], the same resulting expression:[0-9]^3-[0-9]^2-[0-9]^4]

You can use the shorthand expression :d for all instances of [0-9].
:h Hexadecimal digit matches the expression [0-9a-fA-F]+

Use a this expression when you want to match a hexadecimal combination of any upper or lower case letters between 'A' and 'F', and any numbers.

For example, suppose the pages in your website have multiple different background colors and you want to change the color of those pages to black, such as 000000. However, you do not know what the hexadecimal numbers are for the existing colors. Use the following regular expression to find all existing hexadecimal numbers:

\#:h

You could use [0-9a-fA-F] to search, but in this example we combine the back slash (\) and the sharp sign (#) with the hexadecimal digit (:h) syntax. \# matches a non-expression sharp sign (#) and :h matches any sequence of hexadecimal characters.

To replace the existing hexadecimal numbers, type the hexadecimal number of the background color that you want: 000000
:i Identifier matches the expression [a-zA-Z_$][a-zA-Z0-9_$]*

When working with code, if you want to match all program identifiers, you can use the shorthand expression :i to replace having to type the lengthy expression above.
:n Rational number matches the expression ([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)|([0-9]+)

If you want to match all whole numbers that contain a decimal point, you can use the shorthand expression :n to replace having to type the lengthy expression above.
:q Quoted string matches the expression ("[~"]*")|('[~']*')

If you want to match all quotes surrounded by quotation marks, you can use the shorthand expression :q to replace having to type the lengthy expression above.
:w Alphabetic string matches the expression [a-zA-Z]+

This syntax is a shorthand approach to enable you to match one or more alphabetical characters, either lower case or upper case.
:z Decimal integer matches the expression [0-9]+

This syntax is a shorthand approach to enable you match any number from zero or more.